/************** init.html **************/
function query_news(page) {
	sys_loading();
	var parm = $('#queryNewsForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('news-query');
	sys_record_parm('news',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#newsResultList').html(result);
		}
	});
}


function shield_news(code, starturl) {
	$.Zebra_Dialog('确定是否屏蔽'+starturl + ' 链接获取的内容嘛？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('news-shield');
    	   aidExecute_news(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function unshield_news(code, starturl) {
	$.Zebra_Dialog('确定要给'+starturl + '链接获取的内容解除屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('news-unshield');
    	   aidExecute_news(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}
function aidExecute_news(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				query_news();
			} else {
				sys_msg('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}


function save_news() {
	var name = $('#starturl').val();
	if(name == null || name == ''){
		sys_msg('亲，还没有填网址哦！');
		return false;
	}
	var parm = $('#editNewsForm').serialize();
	var url = create_url('news-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功!');
				sys_load_handle('news');
			} else if(result == 'exists') {
				sys_msg('还没有更新内容哦!');
			} else {
				sys_msg('操作失败！')
			}
		}
	});
}

